<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			function createDiamondPattern(n) {
			    let diamond = '';
			    // 上半部分
			    for (let i = 1; i <= n; i += 2) {
			        let spaces = ' '.repeat((n - i) / 2);
			        let stars = '*'.repeat(i);
			        diamond += spaces + stars + '\n';
			    }
			    // 下半部分
			    for (let i = n - 2; i >= 1; i -= 2) {
			        let spaces = ' '.repeat((n - i) / 2);
			        let stars = '*'.repeat(i);
			        diamond += spaces + stars + '\n';
			    }
			    return diamond;
			}
			
			// 示例：输入数字9
			let number = 9;
			console.log(createDiamondPattern(number));
		</script>
	</body>
</html>